<template>
  <div :class="prefixCls" class="relative w-[100vw] h-[100vh]">
    <div class="relative mx-auto flex w-full h-[90%]">
      <div class="relative flex-1 p-30px dark:bg-[var(--login-bg-color)] lt-sm:p-10px">
        <!-- 左上角徽标、名称，右上角的主题切换 -->
        <div
          class="flex items-center justify-between text-black dark:text-white at-2xl:justify-end at-xl:justify-end"
        >
          <div class="flex items-center" :title="title">
            <Logo :lite-mode="true" />
          </div>
          <div class="flex-1"></div>
          <div class="flex items-center justify-end space-x-10px">
            <Screenfull />
            <ThemeSwitch />
            <LocaleDropdown v-if="appStore.getLocale" class="dark:text-white text-black" />
            <SizeDropdown />
          </div>
        </div>
        <!-- 右边的登录界面 -->
        <Transition appear enter-active-class="animate__animated animate__bounceInRight">
          <div
            class="m-auto mt-5 w-full h-full flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px"
          >
            <!-- 账号登录 -->
            <LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
            <!-- 手机登录 -->
            <MobileForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
            <!-- 二维码登录 -->
            <QrCodeForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
            <!-- 注册 -->
            <RegisterForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
            <!-- 三方登录 -->
            <SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
            <!-- 忘记密码 -->
            <ForgetPasswordForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
          </div>
        </Transition>
      </div>
    </div>
    <div class="beian-container beian-fixed">
      <div class="beian-text">
        <Footer v-if="footer" />
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useDesign } from '@/hooks/web/useDesign'
import { Logo } from '@/layout/components/Logo'
import { Screenfull } from '@/layout/components/Screenfull'
import { ThemeSwitch } from '@/layout/components/ThemeSwitch'
import { LocaleDropdown } from '@/layout/components/LocaleDropdown'
import { SizeDropdown } from '@/layout/components/SizeDropdown'
import { Footer } from '@/layout/components/Footer'
import { useAppStore } from '@/store/modules/app'

import {
  LoginForm,
  MobileForm,
  QrCodeForm,
  RegisterForm,
  SSOLoginVue,
  ForgetPasswordForm
} from './components'

defineOptions({ name: 'Login' })

const appStore = useAppStore()
const footer = computed(() => appStore.getFooter)
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('login')

const title = computed(() => appStore.getTitle)
</script>

<style lang="scss" scoped>
$prefix-cls: #{$namespace}-login;

.#{$prefix-cls} {
  overflow: auto;

  &__left {
    &::before {
      position: absolute;
      top: 0;
      left: 0;
      z-index: -1;
      width: 100%;
      height: 100%;
      background-image: url('@/assets/svgs/login-bg.svg');
      background-position: center;
      background-repeat: no-repeat;
      content: '';
    }
  }
}

.beian-fixed {
  position: fixed;
  right: 10px;
  bottom: 20px;
  left: 10px;
}

.beian-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.beian-text {
  margin-top: 40px;
  align-self: center;
  font-size: 14px;
  text-decoration: none;
}
</style>
